home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1035
/
1035.xpi
/
chrome
/
1clickweather.jar
/
content
/
1clickweather
/
js
/
data
/
swa.js
< prev
Wrap
Text File
|
2010-01-04
|
6KB
|
191 lines
// � 2005 The Weather Channel Interactive, Inc. All Rights Reserved.
oDataSources.SWA = function(){ };
oDataSources.SWA.prototype = new oDataSourcesStub;
oDataSources.SWA.prototype.setTooltip = function(){
try{
// first, we make a tooltip object
//var _tooltip = document.createElement("tooltip");
var _tooltip = document.createElement("menupopup");
_tooltip.setAttribute("style", "background-color: #ffffE1;");
if(GlobalToolbarLocation != ToolbarLocations['StatusBar'])
_tooltip.setAttribute("class", "alertTooltip");
//_tooltip.setAttribute("class", "ttBody");
_tooltip.setAttribute("id", ToolbarContainers['SWA'].getID() + ".Tooltip"); // and give it an id
var Box = document.createElement("vbox");
_tooltip.appendChild(Box);
var l = new oXUL.Label(Box, "Severe Weather for " + this.Data['dnam']);
l.Bold();
l.Make();
}catch(e){
debugLog("error creating swa tooltip: " + e);
}
var alertLink = '';
var alertUC = '';
try{
for(var swaID in this.Data){
if(typeof(this.Data[swaID]['uc']) != "undefined"){
var link = this.Data[swaID]['l'] + '&cm_ven=1CW&cm_cat=FFv1.1.9&cm_pla=wx.com-bar&cm_ite=wx-severe-wx-alert&par=1CWFFv1.1.9&site=wx.com-bar';
//We replace this for tracking issues
link = link.replace('www.weather.com', '1cwffweb.weather.com');
var hBox = document.createElement("hbox");
var vBox = document.createElement("vbox");
hBox.appendChild(vBox);
XULSimple.Shim(vBox, 1, 1);
var icon = new oXUL.iconByID(vBox, "swa_bullet_" + this.Data[swaID]['uc']);
icon.setAttribute("onclick", "openLinkInNewTab('" + link + "'); DataContainers['SWA'].popupTooltip(1);");
icon.Make();
var lbl = new oXUL.Label(hBox, this.Data[swaID]['t']);
lbl.setAttribute("onclick", "openLinkInNewTab('" + link + "'); DataContainers['SWA'].popupTooltip(1);");
lbl.setClass("text-link");
lbl.Make();
Box.appendChild(hBox);
if(!alertLink){
alertLink = link;
alertUC = this.Data[swaID]['uc'];
}else if(alertUC < this.Data[swaID]['uc']){
alertLink = link;
alertUC = this.Data[swaID]['uc'];
}
}
}
ToolbarContainers['SWA'].setLink(alertLink);
this.setScreenXY(Box.width, Box.height);
_tooltip.setAttribute("noautohide", true);
_tooltip.setAttribute("position", "before_end");
_tooltip.setAttribute("align", "center");
_tooltip.appendChild(Box);
}catch(e){
debug('error setting swa tooltip: ' + e);
}
try{
var p = document.getElementById(GlobalToolbarLocation);
var t = document.getElementById(ToolbarContainers['SWA'].getID() + ".Tooltip");
if(p && t)
p.removeChild(t);
}catch(e){
debugLog("error removing swa tooltip: " + e);
}
try{
document.getElementById(GlobalToolbarLocation).appendChild(_tooltip);
}catch(e){
debugLog("error appending tooltip: " + this.id + " " + e);
}
// and force the popup to show
this.loadPopup(60);
}
// parse an xml doc into our obs object
oDataSources.SWA.prototype.parseFunc = function(xmlDoc){
this.oldData = this.Data;
this.Data = {}; // flush the Data hash
this.parseHeader(xmlDoc);
// do we have some severe weather alerts?
try{
var swa = xmlDoc.getElementsByTagName("swa")[0].childNodes;
var x = 0;
// loop through all the children under the swa node
for(x = 0; x < swa.length; x++){
try{
if(swa[x].childNodes.length > 1){
var alertID = swa[x].getAttribute("id");
this.Data[alertID] = {};
this.Data[alertID]['uc'] = swa[x].getAttribute("uc");
this.Data[alertID]['t'] = swa[x].getElementsByTagName('t')[0].firstChild.nodeValue;
this.Data[alertID]['l'] = swa[x].getElementsByTagName('l')[0].firstChild.nodeValue;
}
}
catch(e){
// alert(e.message);
}
}
this.setPanel();
this.Finish();
}
// if there are no alerts, hide the panel
catch(e){
for(var p in this.PanelList){
var panel = this.PanelList[p];
ToolbarContainers[panel].Hide();
}
this.Finish();
}
}
oDataSources.SWA.prototype.setPanel = function(){
try{
debugLog("creating SWA panels in SWA.setPanel");
for(var p in this.PanelList){
var panel = this.PanelList[p];
// now we make a pair of hboxs
var panelHbox = document.createElement("hbox");
var i = new oXUL.iconByID(panelHbox, "toolbar_alert");
i.Context(ToolbarContainers['SWA'].getID() + ".Tooltip");
i.onClick("ToolbarContainers['SWA'].Link('swa');");
i.setAttribute("onmouseover", "DataContainers['SWA'].loadPopup();");
i.Make();
ToolbarContainers[panel].Show();
ToolbarContainers[panel].drawFromHbox(panelHbox);
}
this.setTooltip();
}catch(e){
debugLog("error creating SWA panels in SWA.setPanel " + e);
}
}
oDataSources.SWA.prototype.popupTooltip = function(hide){
if(GlobalInitFinished){
if(hide){
clearTimeout(this.Timer);
document.getElementById(ToolbarContainers['SWA'].getID() + ".Tooltip").hidePopup();
}else{
this.setScreenXY(0,0);
//**-- Agregado
if(GlobalToolbarLocation == ToolbarLocations['StatusBar'])
this.XY[1] = this.XY[1] - 40;
document.getElementById(ToolbarContainers['SWA'].getID() + ".Tooltip").showPopup(document.getElementById(ToolbarContainers['SWA'].getID()), this.XY[0], this.XY[1], -1, -1);
}
}
}
oDataSources.SWA.prototype.loadPopup = function(timeout){
//if(timeout){
if(!GlobalDisablePopup){
DataContainers['SWA'].popupTooltip();
this.Timer = setTimeout(toolTip, (3500));
}
//}else{
//}
}
function toolTip(){
DataContainers['SWA'].popupTooltip(1);
}